package com.tanhua.server.controller;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.tanhua.server.service.ReportService;
import com.tanhua.server.vo.ReportVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RequestMapping("testSoul")
@RestController
@Slf4j
public class ReportController {

    @Autowired
    private ReportService reportService;

    @GetMapping("report/{id}")
    public ResponseEntity<ReportVo> testReportResult(@PathVariable("id")Long reportId){

        try {

            ReportVo reportVo = this.reportService.queryReportReslut(reportId);
            if (ObjectUtil.isNotEmpty(reportVo)){
                return ResponseEntity.ok(reportVo);
            }
        } catch (Exception e) {
            log.error("查询结果失败 userId ="+reportId ,e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
